import APIHelper from "../api/APIHelper";
import BaseSingleClass from "../base/BaseSingleClass"

export default class StorageHelper extends BaseSingleClass{
    static CONFIG_NAME='word_match_config'
    culturalIndex=0
    gradeIndex=0
    volumeIndex=0
    versionIndex=0
    
    api_config={
        debug_links:[
            'https://app2.fenzhidao.com/',
            'http://app6.fenzhidao.com/',
            'https://dc.fenzhidao.com/',
            '自定义'
        ],
        index:0,
        token:'9C205A71973AB43334A747E25F867E3473F62C855CFADFBB1EF2991C4E32F2E421E4B7BEA45660BEF4DOB8E71D4B34B535D929B90E82097FDAF978493738DB14',
        account:'13423676525'
    }
    //topic_progress=new Map<string,{selectIndex:number,data:UserAnswerModel[]}>()
    topic_progress={}
    init():void{
        const str=localStorage.getItem(StorageHelper.CONFIG_NAME)
        if(str){
            const config=JSON.parse(str)
            this.culturalIndex=config.culturalIndex
            this.gradeIndex=config.gradeIndex
            this.volumeIndex=config.volumeIndex
            this.api_config=config.api_config
            //this.api_config.account='13423676525'
            this.topic_progress=config.topic_progress
        }else{
            //this.current_book=new BookModel()
            this.save()
        }
    }
    save():void{
        console.log('存储：'+JSON.stringify(this))
        localStorage.setItem(StorageHelper.CONFIG_NAME, JSON.stringify(this))
    }
}